﻿<%@ WebHandler Language="C#" Class="Handler" %>
    
using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using POSGui.Classes;
using POSLogic.BusinessLayer.DataModel;
using POSGui.Presentacion;

public class Handler : IHttpHandler
{

    //private readonly WebserviceWrapper _webserviceWrapper = WebserviceWrapper.GetInstance();

    public void ProcessRequest(HttpContext context)
    {
        try
        {
            var productCode = context.Request.QueryString["id"];
            var response = _webserviceWrapper.GetProductImage(productCode);
            if (!response.ResultOfOperation) return;
            if (((POSLogic.BusinessLayer.DataModel.Product)response.ResultObject).Image == null) return;
            context.Response.ContentType = "image/jpeg";
            context.Response.BinaryWrite(((Product)response.ResultObject).Image);
        }
        catch (System.Exception)
        {
            return;
        }

    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}